public class Test8 {
    public static void main(String[] args) {
        Runnable handler = new Runnable() {
            private int count = 100;

            @Override
            public void run() {
                while (count > 0) {
                    // 使用 sleep 使问题更容易出现
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }

                    System.out.println(Thread.currentThread().getName() + ":" + count--);
                }
            }
        };

        new Thread(handler).start();
        new Thread(handler).start();
    }
}
